package org.hdax.dm.controller;

import org.hdax.dm.request.ItemRequest;
import org.hdax.dm.service.DmItemService;
import org.hdax.dm.service.DmItemTypeService;
import org.hdax.dm.vo.CommonResponse;
import org.hdax.dm.vo.entity.item.VoDmItem;
import org.hdax.dm.vo.entity.item.VoDmItemTwo;
import org.hdax.dm.vo.entity.item.VoDmItems;
import org.hdax.dm.vo.entity.item_type.VoDmItemType;
import org.hdax.dm.vo.entity.item_type.VoDmItemTypeTwo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Controller
@RequestMapping
public class HomePageConstoller {

    @Autowired
    private DmItemTypeService dmItemTypeService;

    @Autowired
    private DmItemService dmItemService;

    /**
     * 获取所有的商品分类
     *
     * @return
     */
    @PostMapping(path = "/p/index/queryAllType")
    @ResponseBody
    public CommonResponse<List<VoDmItemType>> queryAllType() {
        return dmItemTypeService.queryAllType();
    }


    /**
     * 获取首页横向导航数据
     *
     * @return
     */
    @PostMapping(path = "/p/index/queryTransverse")
    @ResponseBody
    public CommonResponse<List<VoDmItemTypeTwo>> queryTransverse() {
        return dmItemTypeService.queryTransverse();
    }


    /**
     * 首页轮播图接口
     *
     * @return
     */
    @PostMapping(path = "/p/index/queryBanner")
    @ResponseBody
    public CommonResponse<List<VoDmItem>> queryBanner() {
        return dmItemService.queryBanner();
    }

    /**
     * 今日推荐接口
     *
     * @return
     */
    @PostMapping(path = "/p/index/queryTodayRecommend")
    @ResponseBody
    public CommonResponse<List<VoDmItem>> queryTodayRecommend() {
        return dmItemService.queryTodayRecommend();
    }


    /**
     * 首页返回不同楼层展示数据
     */
    @PostMapping(path = "/p/index/queryFloorItems")
    @ResponseBody
    public CommonResponse<List<VoDmItems>> queryToSaleItem() {
        return dmItemService.queryToSaleItem();
    }

    /**
     * 不同分类排行
     *
     * @return
     */
    @PostMapping(path = "/p/index/queryHotItems")
    @ResponseBody
    public CommonResponse<List<VoDmItemTwo>> queryHotItems(@RequestBody ItemRequest itemRequest) {
        return dmItemTypeService.queryHotItems(itemRequest.getItemTypeId());
    }
}
